'''编写一个程序，要求能够将任意Python支持的类型（包括含有半角逗号的字符串）
的列表转储为CSV，并能够重新正确解析为列表。'''
def readList(ls:'list'):
    f = open('ls.csv','w',encoding = 'utf-8')
    for row in ls:
        f.write(','.join(row)+'\n')
        for x in row:
            if x == ',':
                row.replace(',','☘')
    f.close()

def csv2list():
    f = open('ls.csv','r',encoding = 'utf-8')
    ls = []
    for line in f:
        ls.append(line.strip('\n').split(','))
    newls = []
    for row in ls:
        for x in row:
            if x == '☘':
                row.replace('☘',',')
    f.close()
    return ls

ls = [['苍落岁欲晚，','辛苦客方行。'],\
      ['大江静犹浪，','扁舟独且征。'],\
      ['棠枯绛叶尽，','芦冻白花轻。'],\
      ['戍人寒不望，','沙禽迥未惊。'],\
      ['湘波各深浅，','空轸念归情。'],]
readList(ls)
print(csv2list())


    
